//
//  LOArrestee.m
//  LegalObserver
//
//  Created by Roxanne Brittain on 10/30/11.
//  Copyright (c) 2011 Digifit. All rights reserved.
//

#import "LOArrestee.h"
#import "LOAppDelegate.h"

@implementation LOArrestee
@synthesize birthDate, firstName, lastName, age;

-(NSString*)displayName
{
    NSMutableString *name = [NSMutableString new];
    if (firstName && ![firstName isEqualToString:@""]) [name appendFormat:@"%@ ", firstName];
    if (lastName && ![lastName isEqualToString:@""]) [name appendFormat:@"%@ ", lastName];
    if (fullName && ![fullName isEqualToString:@""]) [name appendFormat:@"(%@)", fullName];
    
    return [NSString stringWithString:name];
}

-(NSString*)stringDescription
{
    return [NSString stringWithFormat:@"First Name: %@\nLast Name: %@\nNickname: %@\nBirth date: %@\nEmail: %@\nPhone: %@\nAddress: %@\nNotes: %@\n", firstName, lastName, fullName, [LOAppDelegate stringFromDate:birthDate withTime:NO], email, phone, address, notes];
}

- (void)encodeWithCoder:(NSCoder *)coder {
    [super encodeWithCoder:coder];
    [coder encodeObject:birthDate forKey:@"birthDate"];
    [coder encodeObject:firstName forKey:@"firstName"];
    [coder encodeObject:lastName forKey:@"lastName"];
    [coder encodeObject:age forKey:@"age"];
}

- (id)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    birthDate = [coder decodeObjectForKey:@"birthDate"];
    firstName = [coder decodeObjectForKey:@"firstName"];
    lastName = [coder decodeObjectForKey:@"lastName"];
    age = [coder decodeObjectForKey:@"age"];
    return self;
}

@end
